package cn.iocoder.yudao.module.vote.dal.mysql.voteuserinfodetail;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.vote.dal.dataobject.voteuserinfo.VoteUserInfoDO;
import cn.iocoder.yudao.module.vote.dal.dataobject.voteuserinfodetail.VoteUserInfoDetailDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.vote.controller.admin.voteuserinfodetail.vo.*;

/**
 * 用户信息详情 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface VoteUserInfoDetailMapper extends BaseMapperX<VoteUserInfoDetailDO> {

    default PageResult<VoteUserInfoDetailDO> selectPage(VoteUserInfoDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VoteUserInfoDetailDO>()
                .eqIfPresent(VoteUserInfoDetailDO::getMobile, reqVO.getMobile())
                .eqIfPresent(VoteUserInfoDetailDO::getContent, reqVO.getContent())
                .eqIfPresent(VoteUserInfoDetailDO::getFileUrl, reqVO.getFileUrl())
                .betweenIfPresent(VoteUserInfoDetailDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(VoteUserInfoDetailDO::getId));
    }

    default List<VoteUserInfoDetailDO> selectList(VoteUserInfoDetailExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<VoteUserInfoDetailDO>()
                .eqIfPresent(VoteUserInfoDetailDO::getMobile, reqVO.getMobile())
                .eqIfPresent(VoteUserInfoDetailDO::getContent, reqVO.getContent())
                .eqIfPresent(VoteUserInfoDetailDO::getFileUrl, reqVO.getFileUrl())
                .betweenIfPresent(VoteUserInfoDetailDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(VoteUserInfoDetailDO::getId));
    }

    default int deleteByUserId(Integer userId) {
        return delete(new LambdaQueryWrapper<VoteUserInfoDetailDO>().eq(VoteUserInfoDetailDO::getUserId, userId));
    }

    default int updateByUserId(VoteUserInfoDetailDO detailDO) {
        return update(detailDO,new LambdaQueryWrapper<VoteUserInfoDetailDO>().eq(VoteUserInfoDetailDO::getUserId, detailDO.getUserId()));
    }

    default VoteUserInfoDetailDO selectByUserId(Integer userId) {
        return selectOne(new LambdaQueryWrapper<VoteUserInfoDetailDO>().eq(VoteUserInfoDetailDO::getUserId,userId));
    }

    default VoteUserInfoDetailDO selectByMobile(String mobile) {
        return selectOne(new LambdaQueryWrapper<VoteUserInfoDetailDO>().eq(VoteUserInfoDetailDO::getMobile,mobile));
    }
}
